-
Notifications
You must be signed in to change notification settings - Fork 59
Support "file-less" configuration #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
30e80c9 to
2157ae2
Compare
d14bab2 to
769f878
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a "file-less" configuration system that automatically configures boards using Arduino-compatible header definitions from the device tree, eliminating the need for board-specific overlay files. The system detects supported connector types (arduino_header, arduino_mkr_header, etc.) and automatically maps GPIO pins, enabling support for 200+ Zephyr-supported boards including the Nucleo series.
Changes:
- Added automatic board detection using device tree connector labels (arduino_header, pico_header, etc.)
- Introduced GPIO port/pin abstraction layer with constexpr helper functions for compile-time pin mapping
- Modified tone/noTone implementation to support dynamic timer allocation by tracking pin assignments
- Updated PWM and ADC pin mappings to support both legacy and new connector-based configurations
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 21 comments.
| File | Description |
|---|---|
| cores/arduino/Arduino.h | Adds macro definitions for automatic connector detection (ZARD_CONNECTOR, ZARD_ADC_CONNECTOR, ZARD_PWM_CONNECTOR) and updates digital/analog pin enums to support both legacy and connector-based configurations |
| cores/arduino/zephyrCommon.cpp | Implements GPIO abstraction layer with constexpr functions for pin mapping, updates all GPIO operations to use new abstraction, and modifies tone/noTone for improved timer management |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
165377e to
aa5f7a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9d23221 to
293076c
Compare
|
This PR looks quite interesting, will be on my next list of things to review! |
293076c to
7e1fd4c
Compare
| * Copyright (c) 2026 TOKITA Hiroshi | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can get #161 merged before this, then this will no longer be needed.
d652dbd to
2444ff6
Compare
A new configuration method has been adopted, allowing support to be added with less configuration than before. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
b3744ae to
0dbaf95
Compare
In preparation for improvements to allow the use of GPIOs without device tree definitions, the interface will be changed to specify port and pin instead of `gpio_dt_spec`. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
If digital-gpio-pins is not defined, the pin configuration will be generated using the connector definition. This allows ArduinoCore-Zephyr to be used on boards that have arduino-header defined, without requiring specific configuration in ArduinoCore-Zephyr. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
dd32c52 to
dc41a17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ()) | ||
|
|
||
| const struct adc_dt_spec arduino_adc[] = { | ||
| #if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), adc_pin_gpios) |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arduino_adc is enabled by checking adc_pin_gpios, but the array itself is generated from /zephyr,user/io-channels. This will fail to compile when adc-pin-gpios exists without io-channels, and it also prevents using io-channels unless adc-pin-gpios is present. Guard the array generation based on io_channels (provisioning) and keep association (adc_pin_gpios / connector map) independent.
| #if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), adc_pin_gpios) | |
| #if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), io_channels) |
| pcb = find_gpio_port_callback(port); | ||
| __ASSERT(pcb != nullptr, "gpio_port_callback not found"); | ||
|
|
||
| pcb->pins |= BIT(arduino_pins[pinNumber].pin); | ||
| pcb->pins |= BIT(local_gpio_pin(pinNumber)); | ||
| setInterruptHandler(pinNumber, callback); |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attachInterrupt() can end up with port == nullptr from local_gpio_port(pinNumber) (invalid/unmapped global pin). In that case pcb will be nullptr and the __ASSERT(pcb != nullptr, ...) hard-fails; additionally BIT(local_gpio_pin(pinNumber)) is unsafe if the pin is invalid/out of range. Add an early return when port == nullptr (and validate the computed local pin before using it).
| #if DT_NODE_EXISTS(DT_NODELABEL(arduino_header)) | ||
| #define ZARD_CONNECTOR arduino_header | ||
|
|
||
| #define ZARD_ARDUINO_HEADER_R3_DIGITAL_MAP_0 D16 | ||
| #define ZARD_ARDUINO_HEADER_R3_DIGITAL_MAP_1 D17 |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The connector fallback uses ZARD_CONNECTOR_PIN_NAME() which expands to ZARD_<COMPAT>_DIGITAL_MAP_<n> macros. Only the arduino_header compatible has these _DIGITAL_MAP_ macros defined here; if a board uses arduino_mkr_header / arduino_nano_header / pico_header / boosterpack_header without /zephyr,user/digital-pin-gpios, this will expand to undefined tokens and fail to compile. Either restrict the auto-connector path to compatibles you fully map, or add the missing mapping macros for those connector compatibles.
| #define ZARD_GET_NGPIOS(i, ...) DT_PROP(GET_ARG_N(UTIL_INC(i), __VA_ARGS__), ngpios) | ||
| #define ZARD_SUM_NGPIOS(...) \ | ||
| LISTIFY(NUM_VA_ARGS(__VA_ARGS__), ZARD_GET_NGPIOS, (+), __VA_ARGS__) | ||
|
|
||
| #define ZARD_GLOBAL_GPIO_OFFSET_(ph) \ |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ZARD_GET_NGPIOS uses DT_PROP(..., ngpios) but the runtime global-pin mapping in zephyrCommon.cpp uses DT_PROP_OR(..., ngpios, 0). To keep the compile-time pin constants consistent with runtime behavior (and avoid a hard build failure if any GPIO controller node lacks ngpios), consider switching this to DT_PROP_OR(..., ngpios, 0) as well.
This PR introduce new configuration system without variants/[board].overlay.
Boards that has arduino like connector mostly has define
arduino-header.We can use this information to configure automatically for each boards.
We can support all zephyr supported that has
arduino-header.That means, we make it works for more 200 boards, including Nucleo series.
However, only Blinky works out of the box, and ADC and PWM channels are required.
These should be made into snippets in the future.